Похожие топики
Подскажите плагин или тему в блогах, как ввести при просмотре определенного топика, справа в блоке «Похожие топики», «Новые топики»
<?php ##### [hack] similar_topics_sphinx ##### class LsSimilarTopics extends Module { public function Init() { } public function GetSimilarTopics($oTopic){ $sTitleTags=$oTopic->getTags(); $aTopics=array(); $data=$this->Sphinx_FindSimilarTopics($sTitleTags,SIMILARTOPICS_COUNT+1); if(is_array($data['matches']) && sizeof($data['matches'])>0){ foreach($data['matches'] as $k=>$v) if($k!=$oTopic->getId()) $aTopics[]=$this->Topic_GetTopicById($k); return $aTopics; }else return false; } } ##### [hack] similar_topics_sphinx ##### ?>
##### [hack] SimilarTopics ##### public function FindSimilarTopics($sTerms,$iLimit){ $cacheKey=SEARCH_ENTITY_PREFIX."similartopics_{$sTerms}_{$iLimit}"; if(false===($data=$this->Cache_Get($cacheKey))){ $this->oSphinx->SetMatchMode(SPH_MATCH_ANY); $this->oSphinx->SetLimits(0,$iLimit); if(!is_array($data=$this->oSphinx->Query($sTerms,SEARCH_ENTITY_PREFIX.'topicsIndex'))) return FALSE; # no results = no cache if($data['total']>0) $this->Cache_Set($data,$cacheKey,array(),60*15); } return $data; } ##### [hack] SimilarTopics #####